package com.zx.mes.hyl.autorunner;

import com.zx.mes.hyl.consumer.ConsumeMessageImpl;
import com.zx.mes.hyl.rocket.mq.consume.CommonConsumer;
import com.zx.mes.hyl.rocket.mq.yml.RocketMqProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * consumer 在项目启动后自动消费
 *
 * @author 华云龙
 * @date 2018-12-12
 */
@Component
public class ConsumerApplicationRunner implements ApplicationRunner {

    private static final String PRODUCER_GROUP_NAME = "tx-long-order-add-producer-group-name";

    @Autowired
    private RocketMqProperties rocketMqProperties;

    @Autowired
    private ConsumeMessageImpl consumeMessage;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        /// 要启动的consumer
        new CommonConsumer().consumerConfig(PRODUCER_GROUP_NAME, rocketMqProperties, this.consumeMessage)
                .consumer();
    }
}
